package net.wang.concurrency.test.singleton;


import net.wang.concurrency.annoations.ThreadSafe;

/**
 * 单例模式——饿汉模式  实例是在类加载时创建
 * 线程是安全的
 */
@ThreadSafe
public class SingletonExample2 {

    private SingletonExample2() {

    }

    private static SingletonExample2 instance = new SingletonExample2();

    /**
     * 线程是安全
     *
     * @return
     */
    public static SingletonExample2 getInstance() {
        return instance;
    }
}
